<?php
/**
 * Created by PhpStorm.
 * User: iraklis
 * Date: 1/5/14
 * Time: 3:59 PM
 */

session_start();

include 'config.php';
include 'db_connection.php';

$current_user = htmlspecialchars($_GET['username']);
$current_pass = $_GET['password'];
$current_pass_enc = sha1($current_pass);
$query = mysql_query("SELECT u_id FROM USERS WHERE username = '$current_user' AND password = '$current_pass_enc'");
$count = mysql_num_rows($query);
$row = mysql_fetch_row($query);

if ($count == 1) {
    $username = $current_user;
    $password = $current_pass;
    $userID = $row[0];

    echo '{"userID":' . $userID . '}';
}
else {
    echo '{"userID":' . -1 . '}';
}


